package com.yowasa.xiuxian.engine.battle.strategy.drop.all;

import com.google.common.collect.Lists;
import com.yowasa.xiuxian.annoations.BS;
import com.yowasa.xiuxian.engine.battle.strategy.CalAbility;
import com.yowasa.xiuxian.engine.battle.strategy.InherentStrategy;
import com.yowasa.xiuxian.entity.bo.battle.BattleContent;
import com.yowasa.xiuxian.entity.bo.battle.UserBattleContent;
import com.yowasa.xiuxian.entity.bo.user.UserBO;
import com.yowasa.xiuxian.entity.enums.ElementEnum;
import com.yowasa.xiuxian.entity.enums.InherentTiming;
import com.yowasa.xiuxian.entity.enums.StageEnum;
import com.yowasa.xiuxian.exception.HandlerException;
import com.yowasa.xiuxian.util.RandomUtil;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.List;

@BS(name = "六道轮转",upAbility = 4,needTravel = 1000)
@Order(-1001)
@Component
public class LiuDaoLunZhuan extends CalAbility implements InherentStrategy {

    @Override
    public void action(UserBattleContent first, UserBattleContent second, BattleContent content) {

        int needMp = first.getBattleInfo().getMp() - first.getBattleInfo().getCmp();
        int v = (int) (first.getBattleInfo().getMp() * 0.05);
        int can = Math.min(needMp, v);
        first.getBattleInfo().setCmp(first.getBattleInfo().getCmp() + can);
        content.getMsgLog().add("你因六道轮转，回复了"+can+"点法力值");
    }

    @Override
    public void limit(UserBO user) {

        if (user.getStage() < StageEnum.JIN_DAN.getLevel()) {
            throw new HandlerException("学习/使用六道轮转至少要如曜之金");
        }
    }
    @Override
    public String limitDesc() {
        return "达到如曜之金";
    }

    @Override
    public boolean check(UserBattleContent user, BattleContent content) {
        if (RandomUtil.randomInt(10) < 5) {
            return false;
        }
        if (user.getBattleInfo().getCmp() >= user.getBattleInfo().getMp()) {
            return false;
        }
        return true;
    }

    @Override
    public List<InherentTiming> getTiming() {
        return Lists.newArrayList(InherentTiming.SELF_END);
    }

    @Override
    public String desc() {
        return "自己回合结束时有50%的概率回复 5% mp";
    }

    @Override
    public ElementEnum getElement() {
        return null;
    }
}
